<?php
// 1. 引入支付宝SDK
require_once('AopSdk.php');

// 2. 配置参数
$appId = '2021004156624058';
$rsaPrivateKey = 'MIIBszCCAVegAwIBAgIIaeL+wBcKxnswDAYIKoEcz1UBg3UFADAuMQswCQYDVQQG
EwJDTjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RDQTAeFw0xMjA3MTQw
MzExNTlaFw00MjA3MDcwMzExNTlaMC4xCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVO
UkNBQzEPMA0GA1UEAwwGUk9PVENBMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE
MPCca6pmgcchsTf2UnBeL9rtp4nw+itk1Kzrmbnqo05lUwkwlWK+4OIrtFdAqnRT
V7Q9v1htkv42TsIutzd126NdMFswHwYDVR0jBBgwFoAUTDKxl9kzG8SmBcHG5Yti
W/CXdlgwDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFEwysZfZ
MxvEpgXBxuWLYlvwl3ZYMAwGCCqBHM9VAYN1BQADSAAwRQIgG1bSLeOXp3oB8H7b
53W+CKOPl2PknmWEq/lMhtn25HkCIQDaHDgWxWFtnCrBjH16/W3Ezn7/U/Vjo5xI
pDoiVhsLwg==';
$alipayPublicKey = 'MIIDsjCCApqgAwIBAgIQICQRBG8CO0EuryexkipMSzANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0
aG9yaXR5MTkwNwYDVQQDDDBBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENs
YXNzIDIgUjEwHhcNMjQxMTA0MDczMDMyWhcNMjkxMTAzMDczMDMyWjCBkjELMAkGA1UEBhMCQ04x
LTArBgNVBAoMJOmDkeW3numfs+i1lue9kee7nOenkeaKgOaciemZkOWFrOWPuDEPMA0GA1UECwwG
QWxpcGF5MUMwQQYDVQQDDDrmlK/ku5jlrp0o5Lit5Zu9Kee9kee7nOaKgOacr+aciemZkOWFrOWP
uC0yMDg4ODQxNTg1MzU2MTE3MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAveeiOkiF
YfNsT5KWF4K9lIFAeIe7Z3YL9GugCAuUMzjlouhrg1yzpoaEqEsfcVxxSiK/0w0f7b9om8njDd0Q
0mntcHi0ZhHRiuYV7yKsLLQvN7FVoQX0sj2Z/Kcd/O1dTE5bFR7xEdtdf2x+d6THmGyvCHsUk0Aq
kVePbEalXTOb7PojE2ds/AcJHe75KTgDiHkLJL3VPQLVUK7nrazdWK8eK6a1SzwfUslt143PSmRE
7pvTWQif13mi6FfRP85IqUK/duf2OIZqOnaxAcBKoPIoP/eetM0NfFVah5qHiax8vxgE3fWKfAEz
lghUy+x4BB3ORofULBGvzoGjHMgL6wIDAQABoxIwEDAOBgNVHQ8BAf8EBAMCA/gwDQYJKoZIhvcN
AQELBQADggEBAJiCWWop0mQYkm/gMxnuva5aEiaVdOYIif+rVdEExpttistUrzt4q6nGbO68XyxN
s/78DeIXiLzvT5abchwXcRiM55QzLU0IVxoGukEMjkf0nhdCJkrOHQVr9EjBmx2IRf2E0saKRvFa
6sQ7aPO+e+5P1HRQ0835MtXu/Onlt2K0VIxb/X1+CY7aM0tE6iFx+jyfdsJh1m8/9UZUe5aCD430
0D6xzJfZB0IfNe8T5oVM1wCDkK5iYo85EmkgIAd+s70XoOTgF9TWqMwNcwQ3FiZ7F6/MdoBzNOLj
KxOQAtYofBo0HZffnTTATY4Rh57pUpX+E8XZOYOUKnfhNwsPVCU=';

// 3. 创建AopClient实例
$aop = new AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = $appId;
$aop->rsaPrivateKey = $rsaPrivateKey;
$aop->alipayrsaPublicKey = $alipayPublicKey;
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset = 'UTF-8';
$aop->format = 'json';

// 4. 实例化具体的请求类，这里以AlipayTradePagePay为例
$request = new AlipayTradePagePayRequest();

// 5. 设置请求参数，假设订单金额为100元
$bizContent = array(
'out_trade_no' => '商户订单号',
'product_code' => 'FAST_INSTANT_TRADE_PAY',
'total_amount' => '100.00',
'subject' => '商品标题'
);

$request->setBizContent(json_encode($bizContent));

// 6. 发起请求
$response = $aop->pageExecute($request);

// 7. 打印支付页面，用户扫码支付
echo $response;

// 8. 支付成功后，支付宝会为商家提供异步通知，商家需要实现异步通知接口
